<template>
  <div class="header-container">
    <div>
      <div class="header-content">
        <span class="header-title">{{ homework.name }}</span>
        <div class="header-action">
          <div class="header-linkAction">
            <a v-show="finished === 1"
               @click="detail">作业详情</a>
            <a>共享作业</a>
          </div>
          <a class="header-back"
             v-show="!ifWrite"
             @click="back">返回</a>
          <a class="header-back"
             @click="backToWrite"
             v-show="ifWrite">返回</a>
        </div>
      </div>
    </div>


    <el-dialog class="detail"
               :visible.sync="showIframe"
               title="作业详情"
               style="z-index: 2007;">
      <homework-detail :homework="homework" :show-iframe="ifContext"/>
    </el-dialog>


  </div>
</template>


<script>
import HomeworkDetail from '@/views/teacher/component/HomeworkDetail'

export default {
  components: {
    HomeworkDetail,

  },
  props: {
    item: {},
    homework: {},
    finished: 0,
    stu: [],
    ifWrite: Boolean,
  },
  data() {
    return {
      showIframe: false,
      title: '',
      ifContext: false,
    }
  },
  created() {

    this.init()
  },

  methods: {
    async init() {



    },

    // 作业详情
    detail(){
      this.showIframe = true
    },
    // 从作业详情页面返回到课程页面
    back() {
      this.$router.push({
        name: 'course',
        query: {
          item: JSON.stringify(this.item),
          isActive: 5
        }

      }).catch(r => console.log(r))
    },
    // 返回到作业详情页面
    backToWrite() {

      this.$router.push({
        name: 'stuHomeworkView',
        query: {
          item: JSON.stringify(this.item),
          stu: JSON.stringify(this.stu),
        }

      }).catch(r => console.log(r))
    },
  }
}
</script>

<style scoped>
*, :after, :before {
  box-sizing: border-box;
}

div {
  display: block;
  unicode-bidi: isolate;
}


.header-content {
  left: 0;
  right: 0;
  top: 0;
  height: 50px;
  line-height: 50px;
  overflow: hidden;
  font-size: 16px;
  -webkit-box-shadow: 0 0 5px rgba(145, 145, 145, 0.3);
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  z-index: 5;
  background-color: #fff;
  padding: 0 20px;
  box-shadow: 0 0 5px rgba(145, 145, 145, 0.3);
}

.header-title {
  display: inline-block;
  max-width: 70%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


div {
  font-size: 100%;
  font-weight: normal;
  vertical-align: baseline;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  word-break: normal;
}

.header-action {
  float: right;
}

.header-linkAction {
  margin-right: 8px;
  display: inline-block;
  font-size: 0px;
}

.header-linkAction a {
  margin-left: 20px;
  font-size: 14px;
  color: #56b5f5;
}

a {
  text-decoration: none;
}

.header-back {
  color: #fff;
  font-size: 14px;
  padding: 5px 15px;
  background-color: #ea5947;
  border-radius: 5px;
  cursor: pointer;
}




::v-deep .el-dialog__wrapper {
  position: fixed;
  top: 0;
  bottom: 0;
  overflow: auto;
  margin: 0;
}

::v-deep .el-dialog {
  width: 800px!important;
  border-top: 4px solid #ea5947;
  margin-top: 5vh!important;
  position: relative;
  -webkit-box-shadow: none;
  box-sizing: border-box;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,3);
  border-radius: 2px;
}

::v-deep .el-dialog__header {
  padding: 20px;
  padding-bottom: 10px;
}

::v-deep .el-dialog__body {
  color: #606266;
  line-height: 24px;
  font-size: 14px;
  padding: 30px 20px;
}
</style>